home *** CD-ROM | disk | FTP | other *** search
/ The X-Philes (2nd Revision) / The X-Philes Number 1 (1995).iso / xphiles / hp48hor1 / calgen9.src < prev    next >
Text File  |  1990-10-18  |  1KB  |  67 lines

  1. %%HP: T(3)A(D)F(.);
  2.  
  3. @
  4. @ Written by Eric B. Davis
  5. @ EXTENSIVELY Speed and Space Optimized by:
  6. @    Eddie Wilborne
  7. @    Pete Wilson
  8. @
  9. @ Enter the month and year on the stack
  10. @ and this program will generate a calendar.
  11. @ For July, 1990 requires 0.6721 seconds (7 times faster, 1/3 size)
  12. @
  13. @ [User Friendly Feature added by J.Horn: automatically uses current month
  14. @   if none is given.  -jkh-]
  15.  
  16. \<<
  17.   DEPTH
  18.   IF 2 <
  19.   THEN DATE IP DATE 100 * FP 10000 *
  20.   END 1E6 / .01 + \-> mon yrb
  21.  
  22.   \<< 
  23.     yrb mon + DUP 
  24.  
  25.     IF mon 12 ==              @ are we doing december?
  26.     THEN yrb 1.000001 +       @ compute jan of next year
  27.     ELSE yrb mon 1 + +        @ compute first day of next month
  28.     END
  29.  
  30.     DDAYS 3 *
  31.  
  32.     1.0518 ROT DDAYS 7 MOD NEG 7 + 3 *
  33.  
  34.     \-> ndays n
  35.         @ ndays is # days in month times 3
  36.     @ n is # days in first week times 3
  37.  
  38.     \<<
  39.  
  40.     @ The following string ends in a character 10, i.e. a line-feed
  41.         "Su Mo Tu We Th Fr Sa\010"
  42.  
  43.         "                  " 1 21 n - SUB
  44.  
  45.         " 1  2  3  4  5  6  7  8  9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31             "
  46.  
  47.     0 84 FOR o
  48.         n o + 
  49.     @ The following string contains a character 10, i.e. a line-feed
  50.             "\010"
  51.         REPL
  52.     21 STEP
  53.  
  54.     1 ndays SUB
  55.  
  56.     +    @ add padding for first week
  57.     +    @ add day of week header line
  58.  
  59.     CLLCD
  60.     1 DISP
  61.     7 FREEZE
  62.    \>>
  63.  
  64.   \>>
  65.  
  66. \>>
  67.